package ct.common.constant;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

/**
 * @Author Jeremy Zheng
 * @Date 2021/2/22 0:36
 * @Version 1.0
 * 通过读取配置文件的方式获取常量的类
 */
public class ConfigConstant {
    private static Map<String, String> valueMap = new HashMap<>();
    static {
        ResourceBundle ct=ResourceBundle.getBundle("ct");
        Enumeration<String> enums=ct.getKeys();
        while (enums.hasMoreElements()){
            String key=enums.nextElement();
            String value=ct.getString(key);
            valueMap.put(key,value);
        }

    }
    public static String getVal(String key){
        return valueMap.get(key);
    }

    public static void main(String[] args) {
        System.out.println(ConfigConstant.getVal("ct.cf.info"));
    }
}
